/*
 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
 *
 * HDF is dual licensed: you can use it either under the terms of
 * the GPL, or the BSD license, at your option.
 * See the LICENSE file in the root of this repository for complete details.
 */

/**
 * @addtogroup WLAN
 * @{
 *
 * @brief Provides cross-OS migration, component adaptation, and modular assembly and compilation.
 *
 * Based on the unified APIs provided by the WLAN module, developers of the Hardware Driver Interface
 * (HDI) are capable of creating, disabling, scanning for, and connecting to WLAN hotspots, managing WLAN chips,
 * network devices, and power, and applying for, releasing, and moving network data buffers.
 *
 * @since 1.0
 * @version 1.0
 */

/**
 * @file hdf_wifi_product.h
 *
 * @brief Declares the data structure of the WLAN module.
 *
 * @since 1.0
 * @version 1.0
 */

#ifndef HDFLITE_HDF_WIFI_PRODUCT_H
#define HDFLITE_HDF_WIFI_PRODUCT_H

#include "hdf_device_desc.h"
#include "hdf_wlan_config.h"
#include "hdf_wlan_power_manager.h"
#include "hdf_wlan_reset_manager.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief Defines the WLAN chip manufacturer.
 *
 * @since 1.0
 * @version 1.0
 */
struct HdfWlanManufacturer {
    int32_t vendorId;           /**< Vendor ID of the chip */
    int32_t deviceId;           /**< Device ID of the chip */
};

/**
 * @brief Indicates the maximum number of interfaces.
 *
 * The value is <b>32</b>.
 * @since 1.0
 * @version 1.0
 */
#define MAX_IF_COUNT 32

/**
 * @brief Defines the WLAN device.
 *
 * @since 1.0
 */
struct HdfWlanDevice {
    uint8_t id;
    const char *driverName;                     /**< Driver name */
    const char *chipName;                       /**< Chip name */
    uint32_t netIfMap;                          /**< WLAN device bitmap */
    struct HdfWlanManufacturer manufacturer;    /**< WLAN device manufacturer */
    struct ResetManager *reset;                 /**< Chip reset management API */
    struct PowerManager *powers;                /**< Chip power management APIs */
};

/**
 * @brief Initializes the WLAN module.
 *
 * @param device Indicates the pointer to the Hardware Driver Foundation (HDF) device.
 * @param config Indicates the pointer to the WLAN module configuration generated by
 * the HDF Configuration Source (HCS).
 *
 * @return Returns <b>0</b> if the WLAN module is initialized; returns a negative value otherwise.
 *
 * @since 1.0
 * @version 1.0
 */
int HdfWlanInitProduct(struct HdfDeviceObject *device, const struct HdfConfigWlanModuleConfig *config);

/**
 * @brief Obtains the data structure of the WLAN module.
 *
 * @return Returns the data structure if obtained; returns <b>NULL</b> otherwise.
 *
 * @since 1.0
 * @version 1.0
 */
struct WifiModule* HdfWlanGetModule(void);

/**
 * @brief Obtains the <b>HdfWlanDevice</b> structure.
 *
 * @param chipId Indicates the chip ID.
 *
 * @return Returns the pointer to the <b>HdfWlanDevice</b> structure if obtained; returns <b>NULL</b> otherwise.
 *
 * @since 1.1
 * @version 1.0
 */
struct HdfWlanDevice *HdfWlanGetWlanDevice(uint8_t chipId);

/**
 * @brief Send broadcast event.
 *
 * @param id Indicates the ID of the event to send.
 * @param data Indicates the pointer to the event information.
 *
 * @return Returns <b>0</b> if the broadcast event is sent; returns a negative value otherwise.
 *
 * @since 1.0
 * @version 1.0
 */
int HdfWlanSendBroadcastEvent(uint32_t id, const struct HdfSBuf *data);

/**
 * @brief Adds a WLAN device.
 *
 * @param device Indicates the pointer to the device to add.
 *
 * @return Returns <b>0</b> if the WLAN device is added; returns a negative value otherwise.
 *
 * @since 1.0
 * @version 1.0
 */
int HdfWlanAddDevice(struct HdfWlanDevice *device);

/**
 * @brief Deinitializes the WLAN module.
 *
 * @since 1.0
 * @version 1.0
 */
void HdfWlanDeinitProduct(void);

#ifdef __cplusplus
}
#endif
#endif // HDFLITE_HDF_WIFI_PRODUCT_H
/** @} */
